package com.oscroll.singleton.lesson;


import java.util.HashMap;
import java.util.Map;

public class Register {

    private Register() {

    }

    // 类似IOC容器
    private static Map<String, Object> register = new HashMap<String, Object>();

    public static Register getInstance(String name) {
        if (name == null) {
            name = Register.class.getName();
        }

        if (register.get(name) == null) {
            register.put(name, new Register());
        }

        return (Register) register.get(name);
    }
}
